<?php

function clean_file_name($Raw){
    $Raw = trim(strtolower($Raw));
    $RemoveChars  = array( "([\40])" , "([^a-zA-Z0-9-])", "(-{2,})" );
    $ReplaceWith = array("-", "", "-");
    return preg_replace($RemoveChars, $ReplaceWith, $Raw);
} 

function build_job_link($trade,$area,$id){

$link = '/job/'.clean_file_name($trade).'/'.clean_file_name($area).'/'.$id;

return $link;

}

function build_tradesman_link($company_name,$id){

$link = '/tradesman/'.$id.'/'.clean_file_name($company_name);

return $link;

}

?>